#include "StatusEvent.h"

namespace Impp
{

DEFINE_EVENT_TYPE(EVT_BUDDY_STATUS_CHANGED)
DEFINE_EVENT_TYPE(EVT_OWN_STATUS_CHANGED)
DEFINE_EVENT_TYPE(EVT_OWN_STATUS_CHANGING)

StatusEvent::StatusEvent(Buddy* b, const Status & oldS,const Status & newS, const wxString & oldStatusMsg, const wxString & statusMsg, const StatusEventType & statusEventType, const StatusConnectionType & statusConnType, wxEventType eventType, int id) :
	wxNotifyEvent(eventType,id),
	buddy(b),
	oldStatus(oldS),
	newStatus(newS),
	oldStatusMsg(oldStatusMsg),
	statusMsg(statusMsg),
	statusEventType(statusEventType),
	statusConnType(statusConnType)
{
}

StatusEvent::~StatusEvent()
{
}

Buddy* StatusEvent::getBuddy(){
	return buddy;
}
Status StatusEvent::getOldStatus(){
	return oldStatus;
}
Status StatusEvent::getNewStatus(){
	return newStatus;
}

wxEvent* StatusEvent::Clone() const {
	return new StatusEvent(*this);
}

wxString StatusEvent::getStatusMsg(){
	return statusMsg;
}
StatusEventType StatusEvent::getStatusEventType(){
	return statusEventType;
}

StatusConnectionType StatusEvent::getStatusConnectionType(){
	return statusConnType;
}

bool StatusEvent::isStatusDifferent(bool ignoreCustom){
	if(!ignoreCustom){
		return oldStatus != newStatus;
	}else{
		Status tmpOldStatus = oldStatus;
		Status tmpNewStatus = newStatus;
		tmpOldStatus.setExtraStatus(0);
		tmpNewStatus.setExtraStatus(0);
		return tmpNewStatus!=tmpOldStatus;
	}

}

bool StatusEvent::isMsgDifferent(){
	return oldStatusMsg != statusMsg;
}

void StatusEvent::changeStatusMsgTo(const wxString& newStatusMsg){
	wxASSERT_MSG(GetEventType() == EVT_OWN_STATUS_CHANGING, wxT("StatusEvent::changeStatusMsgTo: only allowed for EVT_OWN_STATUS_CHANGING-Events"));
	statusMsg = newStatusMsg;
}

}
